<template>
  <div class="recommend">
    <my-swiper
      :focusList="focusList"
      ></my-swiper>
    <!-- nav部分 -->
    <nav-bar :tomatoes="tomatoes"></nav-bar>
    <!-- 下载app的banner图片 -->
    <download-img v-if="vissable"></download-img>
    <!-- 主要内容 -->
    <xy-content
      v-for="(item, index) in content_xy"
      :key="index"
      :infoList="item.albumBriefDetailInfos"
      :moduleInfo="item.moduleInfo"
    ></xy-content>

    <recom-content :moduleT="moduleT"></recom-content>

    <my-footer v-if="vissable"></my-footer>

    <my-load v-if="isShow"></my-load>
    
  </div>
</template>

<script>
import { Dialog } from "vant";
import { initHomeIndexData } from "@/request/api.js"
export default {
  name: "Recommend",
  data() {
    return {
      moduleT:"youshengshu",
      tomatoes: [],
      content_xy: [],
      comlist: [],
      isShow: false,
      vissable:false,
      focusList:[],
      isShow:false
    };
  },
  watch:{
    tomatoes:{
      immediate:true,
      deep:true,
      handler(val){
        if(val.length > 0){
          this.vissable = true
        }
        
      }
    }
  },
  components: {},
  created() {
    this.initData();
  
  },
  methods: {
    initData() {
      let flag = localStorage.getItem('flag')
      if(flag){
        this.isShow = flag
      }
     initHomeIndexData("youshengshu")
        .then((res) => {
          let module = res.data.data.moduleContent;
          this.tomatoes = module.tomatoes;
          let list = module.moduleRankDatas;
          this.content_xy = list;
          module.focusImages.forEach(item=>{
          let obj = {
            img:item.adFocusPictureDetail.cover
          }

          this.focusList.push(obj)

          
        })
        if(this.tomatoes.length > 0){
            this.isShow = false
            localStorage.setItem('flag',this.isShow)
          }
          // let timer = setInterval(() => {
          //   this.isShow = false;
          //   localStorage.setItem("loading", false);
          // }, 500);
        })
        .catch((err) => {
          console.log("数据获取失败");
        });
    },

    
  },
};
</script>

<style lang="scss" scoped>
</style>

